package ch3oopexer1;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
import org.w3c.dom.ls.LSOutput;

import java.util.Arrays;
import java.util.Scanner;

/*一商场(有名称，地址等信息)的会员系统中，有多个会员，用对象数组表示，假设为100个，
会员属性有会员号，姓名，手机号，积分，

0：添加新会员开卡的方法（添加新会员，参数如何处理？）
 方法申明如下：public boolean add(Card c)*/
public class MarketTest {
    public static void main(String[] args) {
        Market m = new Market();
        m.marketName="万达";
        m.address="义乌";

        VIP[] viparr = new VIP[3];
        m.vip=viparr;
        Scanner scan = new Scanner(System.in);
        while(true){
            System.out.println("1.添加会员");
            System.out.println("2.增加用户积分");
            System.out.println("3.显示商行信息");
            System.out.println("4.添加会员（会员编号不重复）");
            System.out.println("5.兑换礼品");
            System.out.println("6.退出");

            int chooice = scan.nextInt();
            VIP vip = new VIP();
            switch (chooice){
                case 1:
                    System.out.println("***********8添加会员8**********");
                    System.out.println("请输入会员信息：");
                    while(true) {
                        System.out.println("请输入会员编号：");
                        vip.number = scan.next();
                        System.out.println("请输入会员名字：");
                        vip.name = scan.next();
                        System.out.println("请输入会员电话：");
                        vip.phone = scan.next();
                        System.out.println("请输入会员积分：");
                        vip.score = scan.nextDouble();
                        m.add(vip);
                        break;
                    }

                    break;
                case 2:
                    System.out.println("***********8增加用户积分8**********");
                    System.out.print("请输入要增长的会员账号：");
                    String zZNum = scan.next();
                    System.out.print("请输入增涨的会员积分：");
                    double zZScore = scan.nextDouble();
                    m.inc(zZNum,zZScore);
                    m.add(vip);
                    break;
                case 3:
                    System.out.println("3.显示商场及其会员信息");
                    m.show();
                    //会员号，姓名，手机号，积分，
                    for(int i=0;i<m.acoount;i++) {
                        System.out.println("会员号：" + viparr[i].number + " ，姓名：" + viparr[i].name +
                                " ,手机号：" + viparr[i].phone + " ，积分：" + viparr[i].score);

                    }
                    break;
                case 4:
                    System.out.println("请输入要添加额的会员的会员编号：");
                    String addNum = scan.next();
                    boolean isTrue = m.checkCardNoRepeat(addNum);
                    if(isTrue==true ){
                        vip.number=addNum;
                        System.out.println("请输入会员名字：");
                        vip.name = scan.next();
                        System.out.println("请输入会员电话：");
                        vip.phone = scan.next();
                        System.out.println("请输入会员积分：");
                        vip.score = scan.nextDouble();
                        m.add(vip);
                        break;
                    }else{
                        break;
                    }

                case 5:
                    System.out.println("1：100分兑换餐巾纸一包；");
                    System.out.println("2：400分兑换剃须刀一把；");
                    System.out.println("3：1000分兑换炒锅一个；");

                    System.out.println("请输入会员编号：");
                    String exNum = scan.next();
                    System.out.println("请输入礼品类型（1~3）：");
                    int exLX = 0;
                    while(true){
                         exLX = scan.nextInt();
                        if(exLX<0||exLX>3){
                            System.out.println("输入错误，重新输入！");
                        }
                        break;
                    }
                    String exchange = m.duihuan(exNum,exLX);
                    if(exchange==null){//先考虑出错的情况会好一点，不然会出现问题！（会出现什么问题？）
                        System.out.println("很抱歉你无法参与！");
                        break;//改成break;就可以多次判断了
                    }else if(exchange.equals("Y")){
                        System.out.println("已经兑换成功");
                    }
                    break;
                case 6:
                    System.out.println("是否退出？（Y/N）");
                    String isExit = scan.next();
                if(isExit.equals("Y")){
                    return;
                }
            }
        }
    }
}
